home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
ici
/
ici.cpi
/
syscall.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-27
|
4KB
|
130 lines
#include "fwd.h"
#ifndef NOSYSCALL
#include "func.h"
#include "op.h"
#include "exec.h"
#include <errno.h>
/*
* System calls. We do all the easy ones because they cost so little,
* most of the code being in the kernel. And who can tell what people
* will want anyway?
*/
extern int access(), alarm(), acct(), alarm(), chdir(),
chmod(), chown(), chroot(), close(), creat(),
dup(), fork(), getpid(), getpgrp(),
getppid(), getuid(), geteuid(), getgid(), getegid(),
kill(), link(), lseek(), mkdir(), mknod(),
nice(), open(), pause(), rmdir(), setpgrp(),
setuid(), setgid(), setgid(), signal(), sync(),
ulimit(), umask(), umask(), unlink();
extern int clock(), system(), lockf(), sleep();
STATIC int sys_ret();
STATIC int
sys_simple()
{
long av[4];
if (typecheck(CF_ARG2(), &av[0], &av[1], &av[2], &av[3]))
return 1;
return sys_ret((*CF_ARG1())(av[0], av[1], av[2], av[3]));
}
STATIC int
sys_ret(ret)
int ret;
{
if (ret < 0)
{
error = syserr();
return 1;
}
return int_ret((long)ret);
}
cfunc_t syscall_cfuncs[] =
{
{CF_OBJ, "access", sys_simple, access, "si"},
{CF_OBJ, "alarm", sys_simple, alarm, "i"},
{CF_OBJ, "acct", sys_simple, acct, "s"},
{CF_OBJ, "alarm", sys_simple, alarm, "i"},
{CF_OBJ, "chdir", sys_simple, chdir, "s"},
{CF_OBJ, "chmod", sys_simple, chmod, "si"},
{CF_OBJ, "chown", sys_simple, chown, "sii"},
{CF_OBJ, "chroot", sys_simple, chroot, "s"},
{CF_OBJ, "_close", sys_simple, close, "i"},
{CF_OBJ, "creat", sys_simple, creat, "si"},
{CF_OBJ, "dup", sys_simple, dup, "i"},
/*### exec */
/*### fcntl */
{CF_OBJ, "_exit", sys_simple, (int(*)()) exit,"i"},
{CF_OBJ, "fork", sys_simple, fork, ""},
{CF_OBJ, "getpid", sys_simple, getpid, ""},
{CF_OBJ, "getpgrp", sys_simple, getpgrp, ""},
{CF_OBJ, "getppid", sys_simple, getppid, ""},
{CF_OBJ, "getuid", sys_simple, getuid, ""},
{CF_OBJ, "geteuid", sys_simple, geteuid, ""},
{CF_OBJ, "getgid", sys_simple, getgid, ""},
{CF_OBJ, "getegid", sys_simple, getegid, ""},
/*### fcntl */
{CF_OBJ, "kill", sys_simple, kill, "ii"},
{CF_OBJ, "link", sys_simple, link, "ss"},
{CF_OBJ, "lseek", sys_simple, lseek, "iii"},
{CF_OBJ, "mkdir", sys_simple, mkdir, "si"},
{CF_OBJ, "mknod", sys_simple, mknod, "sii"},
{CF_OBJ, "nice", sys_simple, nice, "i"},
{CF_OBJ, "open", sys_simple, open, "sii"},
{CF_OBJ, "pause", sys_simple, pause, ""},
/* ### pipe */
/* ### poll */
/* ### read */
{CF_OBJ, "rmdir", sys_simple, rmdir, "s"},
{CF_OBJ, "setpgrp", sys_simple, setpgrp, ""},
{CF_OBJ, "setuid", sys_simple, setuid, "i"},
{CF_OBJ, "setgid", sys_simple, setgid, "i"},
{CF_OBJ, "setgid", sys_simple, setgid, "i"},
{CF_OBJ, "signal", sys_simple, signal, "ii"},
/* ### stat */
{CF_OBJ, "sync", sys_simple, sync, ""},
/* ### times */
#ifndef NeXT
{CF_OBJ, "ulimit", sys_simple, ulimit, "ii"},
#endif
{CF_OBJ, "umask", sys_simple, umask, "i"},
{CF_OBJ, "umask", sys_simple, umask, "i"},
/* ### uname */
{CF_OBJ, "unlink", sys_simple, unlink, "s"},
/* ### utime */
/* ### wait */
/* ### write */
/*
* Non system calls, but they act so similar.
*/
{CF_OBJ, "clock", sys_simple, clock, ""},
{CF_OBJ, "system", sys_simple, system, "s"},
{CF_OBJ, "lockf", sys_simple, lockf, "iii"},
{CF_OBJ, "sleep", sys_simple, sleep, "i"},
{CF_OBJ}
};
#if 0
f_unixfuncs()
{
if (def_cfuncs(syscall_cfuncs))
return 1;
return loose_ret(objof(&o_null));
}
cfunc_t unix_cfuncs[] =
{
{CF_OBJ, "unixfuncs", f_unixfuncs},
{CF_OBJ}
};
#endif
#endif /*NOSYSCALL*/